package com.keyingbo.leran.pattern.strategy;

import java.util.HashMap;
import java.util.Map;

/**
 * @Auther: KEYB
 * @Date: 2019-3-15 00:37
 * @Description:
 */
public class ExpDataTest {
    private static  Map<FileTypeEnum,AbstractFileDownload> map = null;
    static {
        map = new HashMap<>(3);
        map.put(FileTypeEnum.EXCEL,new ExcelFileDownload());
        map.put(FileTypeEnum.TEXT,new TextFileDownload());
        map.put(FileTypeEnum.PDF,new PdfFileDownload());
    }
    public static void queryAndExpToFile(Records records,FileTypeEnum typeEnum){
        map.get(typeEnum).doDownload(records);
    }
    public static void main(String[] args) {
        Records records = new Records();
        records.setRecord1("记录1");
        records.setRecord2("记录2");
        records.setRecord3("记录3");
        records.setRecordN("记录N");

        queryAndExpToFile(records,FileTypeEnum.TEXT);
        queryAndExpToFile(records,FileTypeEnum.EXCEL);
        queryAndExpToFile(records,FileTypeEnum.PDF);
    }
}
